package com.hm.prac2;

public class ComparableRectangle extends Rectangle implements Comparable {
    public ComparableRectangle(double width, double length) {
        super(width, length);
    }

    @Override
    public int compareTo(Object o) {
        if(o instanceof Rectangle r1){
            return Double.compare(this.getArea(),r1.getArea());
        }else{
            try {
                throw new Exception("比较类型不符合规则");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
